package com.fiveflavors.suittar.gui.inputpanel;

import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Dimension;

import javax.swing.JPanel;

import com.fiveflavors.suittar.Suittar;

public class SuittarInputPanel extends JPanel {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -8350351424871564353L;
	public static final String MODE_STATUS = "status";
	public static final String MODE_DIRECT_MESSAGE = "direct_message";

	private CardLayout layout = new CardLayout();
	private SuittarInputStatusPanel statusPanel = new SuittarInputStatusPanel();
	private SuittarInputDirectMessagePanel directMessagePanel = new SuittarInputDirectMessagePanel();
	
	private String mode = MODE_STATUS;

	public SuittarInputPanel() {
		setBackground(new Color(154,228,232));
		setPreferredSize(new Dimension(500,50));
		setMinimumSize(new Dimension(500,50));
		setMaximumSize(new Dimension(500,50));
		setLayout(layout);
		add(MODE_STATUS,statusPanel);
		add(MODE_DIRECT_MESSAGE,directMessagePanel);
	}
	
	public void setMode(String mode) {
		this.mode = mode;
		statusPanel.clear();
		directMessagePanel.clear();
		layout.show(this, mode);
		if (mode.equals(MODE_STATUS)) {
	        setPreferredSize(new Dimension(500,50));
	        setMinimumSize(new Dimension(500,50));
	        setMaximumSize(new Dimension(500,50));
		}
		else {
	        setPreferredSize(new Dimension(500,80));
	        setMinimumSize(new Dimension(500,80));
	        setMaximumSize(new Dimension(500,80));			
		}
	}
	
	public String getMode() {
		return mode;
	}
	
	public void addButtonActionListener(Suittar suittar) {
		statusPanel.addButtonActionListener(suittar);
		directMessagePanel.addButtonActionListener(suittar);
	}
	
	public void addEnterActionListener(Suittar suittar) {
		statusPanel.addEnterActionListener(suittar);
		directMessagePanel.addEnterActionListener(suittar);
	}
	
	public SuittarInputStatusPanel getStatusPanel() {
		return statusPanel;
	}
	
	public SuittarInputDirectMessagePanel getDirectMessagePanel() {
		return directMessagePanel;
	}
	
	public void setTextAreaEditable(boolean editable) {
		statusPanel.setTextAreaEditable(editable);
		directMessagePanel.setTextAreaEditable(editable);
	}

}
